package com.rxkj.service.impl;

import com.rxkj.entity.gnss.GnssDeviceVO;
import com.rxkj.entity.rainwater.StationInfo;
import com.rxkj.entity.rainwater.WaterAndRainVO;
import com.rxkj.mapper.StationManageMapper;
import com.rxkj.service.StationManageService;
import com.rxkj.utils.PageData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class StationManageServiceImpl implements StationManageService {

    @Autowired
    private StationManageMapper stationManageMapper;




    @Override
    public List<StationInfo> getHdrtuStationInfo() {
        List<StationInfo> res = stationManageMapper.getHdrtuStationInfo();
        res.forEach(st -> {
            WaterAndRainVO war = stationManageMapper.getRtuDetailsByTermsn(st.getStcdcode());
            st.setStatus(war.getStatus());
            st.setSignalInten(war.getSignalInten());
            st.setVoltage(war.getVoltage());
        });
        return res;
    }

    @Override
    public PageData<StationInfo> getGnssDevInfo(int currentPage, int pageSize, String deviceName) {
        Long totalRows = stationManageMapper.getGnssDevInfoTotal("510521", deviceName);
        PageData<StationInfo> res = new PageData<StationInfo>(currentPage, pageSize, totalRows);
        List<StationInfo> qe = stationManageMapper.getGnssDevInfo("510521", res.getStart(), res.getEnd(), deviceName);
        res.setRows(qe);
        return res;
    }

    @Override
    public Map<String, Object> onePicDevChartsInit() {
        Map<String, Object> res = new HashMap<>();
        int ys,gnss,sl = 0;
        //水雨情
        ys = stationManageMapper.getCountYs();
        //gnss
        gnss = stationManageMapper.getCountGnss("510521");
        // todo 渗压

        res.put("ysDev", ys);
        res.put("gnssDev", gnss);
        res.put("slDev", sl);
        return res;
    }
}
